package net.y2t72.microblog.dao.impl;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public class InitialProperties extends Properties{

	/**
	 * 版本号
	 */
	private static final long serialVersionUID = -912089608611810871L;
	
	/**
	 * log4j
	 */
	private Logger logger = Logger.getLogger(InitialProperties.class);

	/**
	 * 对象自身
	 */
	private static InitialProperties instance;
	
	/**
	 * 单例模式
	 * @return
	 */
	public static InitialProperties getInstance(){
		if(instance == null){
			synchronized (InitialProperties.class) {
				if (instance == null) {
					instance = new InitialProperties();
				}
			}
		}
		return instance;
	}

	/**
	 * 私有构造函数
	 */
	private InitialProperties() {
		try {
			//创建流
			InputStream is = InitialProperties.class.getClassLoader().getResourceAsStream("dbcpconfig.properties");
			
			//读取文件
			load(is);
			
			//关闭流
			is.close();
		} catch (IOException e) {
			logger.error("配置文件读取失败!详细信息:" + e,e.getCause());
		}
	}
}
